﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _16.SubsetInArray
{
    class SubsetInArray
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Which sum:"); 
            int sum = int.Parse(Console.ReadLine());
            Console.WriteLine("n of array:"); 
            int n = int.Parse(Console.ReadLine());
        
            int[] numbers = new int[n];
            for (int i = 0; i < n; i++)
            {
                Console.Write("numbers[{0}]: ", i);
                numbers[i] = int.Parse(Console.ReadLine());
            }
            int counter = 0;
            int currentSum;
            double   lenght = Math.Pow(2, n);
            for (int i = 1; i < lenght; i++)
            {
                currentSum=0;
                for (int j = 0; j < n; j++)
                {
                    currentSum += numbers[j] * MagicOfBinary(number: i, digit: j);
                }
                
                if (currentSum == sum)
                {
                    counter++;
                    Console.WriteLine("yes");
                    for (int j = 0; j < n; j++)
                    {
                        if (MagicOfBinary(number: i, digit: j) == 1)
                        {
                            Console.Write(" {1}{0}{2} + ", numbers[j], numbers[j] < 0 ? "(" : "", numbers[j] < 0 ? ")" : "");
                        }
                    }
                    Console.WriteLine("\b\b= {0}", sum);
                }
            }
            if (counter > 0)
            {
                Console.WriteLine("NO found others!");
            }
            else
            {
                Console.WriteLine("Not found!");
            }
        }

        public static int MagicOfBinary(int number, int digit)
        {
            return (number & (1 << digit))>>digit;
        }
    }
}
